From 0f41512404205a81238828fe2c6c3b4be9b4af8a Mon Sep 17 00:00:00 2001 From: =?utf8?q?=C3=98yvind=20Kol=C3=A5s?= Date: Tue, 23 Aug 2005 07:50:02 +0000 Subject: [PATCH] added process method to conversion class --- ChangeLog | 8 +++++- babl/babl-conversion.c | 59 ++++++++++++++++++++++++++++++++++++++++++ babl/babl-conversion.h | 5 ++++ babl/babl-instance.h | 1 - 4 files changed, 71 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 18743ef..c85c614 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2005-08-23 Øyvind Kolås + + * babl/babl-instance.h: babl_class_name is moved to babl-classes.h + * babl/babl-conversion.h: add a method to the conversion class for the + processing with registered functions. + * babl/babl-fish.c: Use above functions. + 2005-08-23 Øyvind Kolås * babl/babl-memory.[ch]: added additonal sanity checking (only @@ -24,7 +31,6 @@ 2005-08-22 Øyvind Kolås * babl/babl-classes.h: (BabPixelFormat): only a single BablModel. - * babl/babl-fish.h, * babl/babl-pixel-format.h, * tests/babl-html-dump.c: accomodate change. diff --git a/babl/babl-conversion.c b/babl/babl-conversion.c index 2388b11..7b6f668 100644 --- a/babl/babl-conversion.c +++ b/babl/babl-conversion.c @@ -233,4 +233,63 @@ babl_conversion_new (const char *name, } } +static void +babl_conversion_linear_process (BablConversion *conversion, + void *source, + void *destination, + long n) +{ + conversion->function.linear (source, destination, n); +} + +static void +babl_conversion_planar_process (BablConversion *conversion, + BablImage *source, + BablImage *destination, + long n) +{ + conversion->function.planar (source->bands, + source->data, + source->pitch, + destination->bands, + destination->data, + destination->pitch, + n); +} + +/* this is the place to insert usage instrumentation into babl */ +void +babl_conversion_process (BablConversion *conversion, + void *source, + void *destination, + long n) +{ + assert (BABL_IS_BABL (conversion)); + + switch (BABL(conversion)->class_type) + { + case BABL_CONVERSION_TYPE: + babl_conversion_linear_process (conversion, + source, + destination, + n); + break; + case BABL_CONVERSION_MODEL_PLANAR: + assert (BABL_IS_BABL (source)); + assert (BABL_IS_BABL (destination)); + + babl_conversion_planar_process ( conversion, + (BablImage*) source, + (BablImage*) destination, + n); + break; + default: + babl_log ("%s(%s, %p, %p, %li) unhandled conversion type: %s", + __FUNCTION__, conversion->instance.name, source, destination, n, + babl_class_name (conversion->instance.class_type)); + break; + } + +} + BABL_CLASS_TEMPLATE (babl_conversion) diff --git a/babl/babl-conversion.h b/babl/babl-conversion.h index 327de75..286d6a2 100644 --- a/babl/babl-conversion.h +++ b/babl/babl-conversion.h @@ -24,4 +24,9 @@ BABL_DEFINE_CLASS (babl_conversion) +void babl_conversion_process (BablConversion *conversion, + void *source, + void *destination, + long n); + #endif diff --git a/babl/babl-instance.h b/babl/babl-instance.h index cfd7ff2..17f246e 100644 --- a/babl/babl-instance.h +++ b/babl/babl-instance.h @@ -5,7 +5,6 @@ typedef int (*BablEachFunction) (Babl *entry, void *data); -const char *babl_class_name (BablClassType klass); /* these defines are kept here to keep the typing needed in class * headers to a minimum, only the ones overriding the basic api with -- 2.30.2